#ifndef OS_EX_EX2_SOCKET_UTIL_H
#define OS_EX_EX2_SOCKET_UTIL_H

#include <netinet/in.h>

enum GAME_MSG {
    GAME_MSG_STONE,
    GAME_MSG_SCISSORS,
    GAME_MSG_CLOTH,
    GAME_MSG_START_ROUND,
    GAME_MSG_FINAL_LOST,
    GAME_MSG_FINAL_WIN,
    GAME_MSG_FINAL_DRAW,
};

enum WINNER {
    PLAYER_0,
    PLAYER_1,
    DRAW,
};

struct round {
    enum GAME_MSG action[2];
    enum WINNER winner;
};

struct room {
    int player[2];
    size_t rounds_len;
    size_t played_rounds;
    struct round *rounds;
};

void print_endl();

void new_sockaddr(struct sockaddr_in* addr, const char *ip_addr, uint16_t port);

void send_game_msg(int sock, enum GAME_MSG action_type);

enum GAME_MSG recv_game_msg(int sock);

void new_round(struct round* round);

void new_room(struct room* room, int serv_sock, size_t rounds_len);

void destroy_room(struct room* room);

enum WINNER get_winner(enum GAME_MSG action0, enum GAME_MSG action1);

int play_new_round(struct room* room);

#endif